import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { HydratedDocument } from 'mongoose'

export type UserDocument = HydratedDocument<User>

@Schema()
export class User {
  @Prop({ unique: true })
  public id: string

  @Prop({ unique: true })
  public username: string

  @Prop()
  public password: string

  // 角色id数组
  @Prop()
  public roles: string[]

  @Prop()
  public nickname: string

  @Prop()
  public department: string

  @Prop()
  public position: string
}

export const UserSchema = SchemaFactory.createForClass(User)
